using Mysolution.Domain.Repositories;
using Mysolution.Infrastructure.Data;
using Mysolution.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace MySolution.Infrastructure;

public static class ServiceCollectionExtension
{
    public static IServiceCollection AddInfrastructure(this IServiceCollection services,IConfiguration configuration)
    {
        var connectionString =configuration.GetConnectionString("pgsql");
        services.AddDbContext<MysolutionDbContext>(x=>
        {
            x.UseNpgsql(connectionString);
        });
        services.AddScoped(typeof(IRepository<>),typeof(EfRepository<>));

        return services;
    }
}
